<?php
$popup      = true;
$type       = gpc_getStringGet('type');
$idParent   = gpc_getIntGet('id');

$id         = gpc_getIntPost('id');
$textmap	= gpc_getStringPost("textmap");
$xmap		= gpc_getStringPost("xmap");
$ymap		= gpc_getStringPost("ymap");
$zoommap    = gpc_getIntPost('zoommap');

if($actPost=="UpMap")
{
    if($id>0)
    {
        $sql_update = "update tblmap Set ";
        $sql_update.= " cName       = '$textmap',";
        $sql_update.= " fX          = '$xmap',";
        $sql_update.= " fY          = '$ymap',";
        $sql_update.= " iZoom       = '$zoommap' ";
        $sql_update.= " where iId    = $id";
        $dbsql->query($sql_update);
        $alert  = "Update Map Success";
    }else
    {
        $sql_insert = "insert into tblmap(iParentId,cName,cType,fX,fY,iZoom)
                    values($idParent,'$textmap','$type','$xmap','$ymap','$zoommap')";
        $dbsql->query($sql_insert);
        $alert  = "Insert Map Success";
    }
}

$sql_select = "select * from tblmap where cType='$type' and iParentId='$idParent'";
$map        = $dbsql->query_fetch($sql_select);

if(count($map)<=1)
{
    $map    = array();
    $map['fX']  = 16.455286135359106;
    $map['fY']  = 107.58919715881348;
    $map['iZoom']=13;
}
?>